#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
class Linked_list
{
    public:
        Linked_list();
        void li_insert(int student_id,string student_name,int student_score);
        void li_delete();
        void li_print();
    private:
        struct node
        {
            int stu_id;
            string name;
            int score;
            node *next;
        }*start;
};
Linked_list::Linked_list()
{
    this->start=(node *)malloc(sizeof(node));
    this->start->next=NULL;
    //this->start->value=-1;
}
void Linked_list::li_insert(int student_id,string student_name,int student_score)
{
    node *p=this->start;
    while(p->next!=NULL)
    {
        p=p->next;
    }
    node *new_node=(node *)malloc(sizeof(node));
    new_node->stu_id=student_id;
    new_node->name=student_name;
    new_node->score=student_score;
    p->next=new_node;
}
void Linked_list::li_delete()
{
    int cnt=0;node *p=this->start,*q;
    while(p!=NULL)
    {
        q=p;
        p=p->next;
        if(p!=NULL){
            int sc=p->score;
            if(sc%10==8)
            {
                q->next=p->next;
                free(p);
                p=q;
            }
        }
    }
}
void Linked_list::li_print()
{
    node  *p=this->start;
    while(p!=NULL)
    {
        p=p->next;
        if(p!=NULL)
            cout<<p->stu_id<<' '<<p->name<<' '<<p->score<<endl;
    }
}
int main()
{
    int n,student_id,student_score;
    string student_name;
    Linked_list t;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>student_id>>student_name>>student_score;
        t.li_insert(student_id,student_name,student_score);
    }
    t.li_delete();
    t.li_print();
    return 0;
}